using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace TVSGPP.core
{
	public class ExDataGridView : DataGridViewTextBoxCell
	{
		private int m_nLeftColumn = 0;
		private int m_nRightColumn = 0;
		public int LeftColumn
		{
			get
			{
				return this.m_nLeftColumn;
			}
			set
			{
				this.m_nLeftColumn = value;
			}
		}
		public int RightColumn
		{
			get
			{
				return this.m_nRightColumn;
			}
			set
			{
				this.m_nRightColumn = value;
			}
		}
		protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
		{
			try
			{
				int num = base.ColumnIndex - this.m_nLeftColumn;
				Pen pen = new Pen(Brushes.Black);
				graphics.FillRectangle(new SolidBrush(SystemColors.Control), cellBounds);
				graphics.DrawLine(new Pen(new SolidBrush(SystemColors.ControlDark)), cellBounds.Left, cellBounds.Bottom - 1, cellBounds.Right, cellBounds.Bottom - 1);
				if (base.ColumnIndex == this.m_nRightColumn)
				{
					graphics.DrawLine(new Pen(new SolidBrush(SystemColors.ControlDark)), cellBounds.Right - 1, cellBounds.Top, cellBounds.Right - 1, cellBounds.Bottom);
				}
				RectangleF empty = RectangleF.Empty;
				StringFormat stringFormat = new StringFormat();
				stringFormat.Alignment = StringAlignment.Center;
				stringFormat.LineAlignment = StringAlignment.Center;
				stringFormat.Trimming = StringTrimming.EllipsisCharacter;
				int num2 = 0;
				for (int i = this.m_nLeftColumn; i <= this.m_nRightColumn; i++)
				{
					num2 += base.OwningRow.Cells[i].Size.Width;
				}
				int num3 = 0;
				for (int i = this.m_nLeftColumn; i <= base.ColumnIndex - 1; i++)
				{
					num3 += base.OwningRow.Cells[i].Size.Width;
				}
				string s = base.OwningRow.Cells[this.m_nLeftColumn].Value.ToString();
				empty = new RectangleF((float)(cellBounds.Left - num3), (float)cellBounds.Top, (float)num2, (float)cellBounds.Height);
				graphics.DrawString(s, new Font("Arial", 10f, FontStyle.Regular), Brushes.Black, empty, stringFormat);
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex.ToString());
			}
		}
	}
}
